package com.octocat.dao.impl;

import com.octocat.dao.BaseDao;
import com.octocat.dao.UserDao;
import com.octocat.pojo.User;

/**
 * @Author: Octocat
 * @Date : 2021/5/18
 */
public class UserDaoImpl extends BaseDao implements UserDao {

    @Override
    public User queryUserByUserName(String username) {
        String sql = "SELECT username,  userpassword, useremail FROM t_user WHERE username = ? ";
        return queryForOne(User.class,sql,username);
    }

    @Override
    public User queryUserByUserNameAndPassword(String username, String password) {
        String sql = "SELECT username , userpassword, useremail FROM t_user WHERE username = ? AND userpassword = ?";
        return queryForOne(User.class,sql,username,password);
    }

    @Override
    public int saveUserInfo(User user) {
        String sql = "insert into t_user(username,userpassword,useremail) values(?,?,?)";
        return update(sql,user.getUserName(),user.getUserPassword(),user.getUserEmail());
    }
}
